package com.hxc.configs.db;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;

/**
 * 数据库配置
 * */
@Configuration
public class DataSourceConfig {

  @Value("${spring.datasource.prime-data.driver-class-name}")
  private String primeDataDriver;

  @Value("${spring.datasource.prime-data.url}")
  private String primeDataUrl;

  @Value("${spring.datasource.prime-data.username}")
  private String primeDataUsername;

  @Value("${spring.datasource.prime-data.password}")
  private String primeDataPassword;

  @Bean
  public DriverManagerDataSource primeDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(primeDataDriver);
    dataSource.setUrl(primeDataUrl);
    dataSource.setUsername(primeDataUsername);
    dataSource.setPassword(primeDataPassword);
    return dataSource;
  }

  // 配置其他数据库连接（待定占位）
  @Bean
  public DriverManagerDataSource otherDataSource() {
    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName(primeDataDriver);
    dataSource.setUrl(primeDataUrl);
    dataSource.setUsername(primeDataUsername);
    dataSource.setPassword(primeDataPassword);
    return dataSource;
  }
}
